<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网页计时器</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        div {
            width: 500px;
            height: 100px;
            line-height: 100px;
            margin: 0 auto;
            text-align: center;
        }

        span {
            color: pink;
            font-weight: bold;
            font-size: 20px;
        }
    </style>
</head>

<body>
    <div>看我 <span>0</span> 秒了，是不是喜欢我！！！</div>

    <script>
        // 获取标签元素
        const span = document.querySelector('span');
        // 声明计时初始值
        let time = 0;

        // 开启一个定时器
        setInterval(() => {
            time++;
            span.innerHTML = time;
        }, 1000);
    </script>
</body>

</html>